export module spreadsheet;

import <vector>;
import <iostream>;

import spreadsheet_cell;

namespace spreadsheet
{
	export class Spreadsheet
	{
	public:
		Spreadsheet(size_t width, size_t height);
		~Spreadsheet();

		Spreadsheet(const Spreadsheet &src); // copy constructor
		Spreadsheet &operator=(const Spreadsheet &src); // copy Assignment constructor

		Spreadsheet(Spreadsheet &&src) noexcept; // move constructor
		Spreadsheet &operator=(Spreadsheet &&src) noexcept; // move Assignment constructor

		void setCellAt(size_t width, size_t height, const SpreadsheetCell &value);
		const SpreadsheetCell &getCellAt(size_t width, size_t height) const;
		SpreadsheetCell &getCellAt(size_t width, size_t height);

		size_t getId() const;

		void swap(Spreadsheet &other) noexcept;

	private:
		void verifyCoordinate(size_t width, size_t height) const;

	private:
		size_t m_width{ 0 };
		size_t m_height{ 0 };
		SpreadsheetCell **m_cells{ nullptr };

		//
		static inline size_t ms_counter{ 0 };
		const size_t m_id{ 0 };

		// 
		const static inline size_t MaxWidth{ 100 };
        const static inline size_t MaxHeight{ 100 };
	};

	export void swap(Spreadsheet &lhs, Spreadsheet &rhs) noexcept
	{
		lhs.swap(rhs);
	}

	//
	Spreadsheet createObject()
	{
		return Spreadsheet{ 3, 2 };
	}

	export void testSpreadsheet()
	{
		//std::vector<Spreadsheet> vec;
		////vec.reserve(2);
		//for (size_t i{ 0 }; i < 2; i++)
		//{
		//	std::cout << "Iteration " << i << std::endl;
		//	vec.push_back(Spreadsheet{ 100, 100 });
		//	std::cout << std::endl;
		//}

		////
		//Spreadsheet sheet{ 2, 3 };
		//sheet = createObject();

		////
		//Spreadsheet sheet2{ 1, 2 };
		//sheet2 = sheet;

		Spreadsheet sheet1{ 5, 6 };
		SpreadsheetCell &cell1{ sheet1.getCellAt(1, 2) };

		const Spreadsheet sheet2{ 5, 6 };
		const SpreadsheetCell &cell2{ sheet2.getCellAt(1, 1) };

	}
}